package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.FndCodingRuleDetails;
import com.bestow.basic.service.IFndCodingRuleDetailsService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 编码规则明细Controller
 * 
 * @author liliu
 * @date 2022-09-03
 */
@RestController
@RequestMapping("/basic/codingRuleDetails")
public class FndCodingRuleDetailsController extends BaseController
{
    @Autowired
    private IFndCodingRuleDetailsService fndCodingRuleDetailsService;

    /**
     * 查询编码规则明细列表
     */
    @PreAuthorize("@ss.hasPermi('basic:codingRuleDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(FndCodingRuleDetails fndCodingRuleDetails)
    {
        startPage();
        List<FndCodingRuleDetails> list = fndCodingRuleDetailsService.selectFndCodingRuleDetailsList(fndCodingRuleDetails);
        return getDataTable(list);
    }

    /**
     * 导出编码规则明细列表
     */
    @PreAuthorize("@ss.hasPermi('basic:codingRuleDetails:export')")
    @Log(title = "编码规则明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FndCodingRuleDetails fndCodingRuleDetails)
    {
        List<FndCodingRuleDetails> list = fndCodingRuleDetailsService.selectFndCodingRuleDetailsList(fndCodingRuleDetails);
        ExcelUtil<FndCodingRuleDetails> util = new ExcelUtil<FndCodingRuleDetails>(FndCodingRuleDetails.class);
        util.exportExcel(response, list, "编码规则明细数据");
    }

    /**
     * 获取编码规则明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:codingRuleDetails:query')")
    @GetMapping(value = "/{codingRuleLineId}")
    public AjaxResult getInfo(@PathVariable("codingRuleLineId") Long codingRuleLineId)
    {
        return AjaxResult.success(fndCodingRuleDetailsService.selectFndCodingRuleDetailsByCodingRuleLineId(codingRuleLineId));
    }

    /**
     * 新增编码规则明细
     */
    @PreAuthorize("@ss.hasPermi('basic:codingRuleDetails:add')")
    @Log(title = "编码规则明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FndCodingRuleDetails fndCodingRuleDetails)
    {
        return toAjax(fndCodingRuleDetailsService.insertFndCodingRuleDetails(fndCodingRuleDetails));
    }

    /**
     * 修改编码规则明细
     */
    @PreAuthorize("@ss.hasPermi('basic:codingRuleDetails:edit')")
    @Log(title = "编码规则明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FndCodingRuleDetails fndCodingRuleDetails)
    {
        return toAjax(fndCodingRuleDetailsService.updateFndCodingRuleDetails(fndCodingRuleDetails));
    }

    /**
     * 删除编码规则明细
     */
    @PreAuthorize("@ss.hasPermi('basic:codingRuleDetails:remove')")
    @Log(title = "编码规则明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{codingRuleLineIds}")
    public AjaxResult remove(@PathVariable Long[] codingRuleLineIds)
    {
        return toAjax(fndCodingRuleDetailsService.deleteFndCodingRuleDetailsByCodingRuleLineIds(codingRuleLineIds));
    }
}
